package com.coreJava.xianchengchi.testForDingShiPool;

import java.util.concurrent.ScheduledExecutorService;

/**
 * 作者: LCG
 * 日期: 2020/2/10 23:00
 * 描述:
 */
public class TestSchRunable implements Runnable{

    private ScheduledExecutorService scheduledExecutorService;

    public TestSchRunable(ScheduledExecutorService scheduledExecutorService) {
        this.scheduledExecutorService = scheduledExecutorService;
    }

    private int i=0;
    @Override
    public void run() {
        if(i<3){
            i=i+1;
            try {
                Thread.sleep(2000);
                System.out.println("======尝试连接====="+i);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }else{
            scheduledExecutorService.shutdown();
            System.out.println("=====尝试连接失败=====");
        }

    }
}
